<?php
class ActoresController extends AppController {

	var $name = 'Actores';

	function index() {
		$this->Actore->recursive = 0;
		$this->set('actores', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Actor Invalido', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('actore', $this->Actore->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Actore->create();
			if ($this->Actore->save($this->data)) {
				$this->Session->setFlash(__('Actor Guardado', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('El Actor no se guardo', true));
			}
		}
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Actor Invalido', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->Actore->save($this->data)) {
				$this->Session->setFlash(__('Actor Actualizado', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('Actor No Actualizado', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Actore->read(null, $id);
		}
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Actor Invalido', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Actore->delete($id)) {
			$this->Session->setFlash(__('Actor Eliminado', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('El Actor no se Elimino', true));
		$this->redirect(array('action' => 'index'));
	}
}
